﻿// --------------------------------------------------------------------------------------------------------------------- 
// <copyright file="TriangleNumbers.cs" company="Microsoft">
//   Copyright (c) Microsoft Corporation.  All rights reserved. THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// </copyright>
// <summary>
//   Defines the TriangleNumbers type.
// </summary>
// ---------------------------------------------------------------------------------------------------------------------
namespace EulerProblemsCSharp
{
    using System.Collections.Generic;

    /// <summary>
    /// Generates triangle numbers
    /// </summary>
    public class TriangleNumbers
    {
        /// <summary>
        /// Gets a sequence of triangle numbers.
        /// </summary>
        /// <returns>
        /// Sequence of triangle numbers.
        /// </returns>
        public IEnumerable<int> Sequence
        {
            get
            {
                var i = 0;
                var total = 0;

                while (true)
                {
                    yield return total += ++i;
                }
            }
        }
    }
}